package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.VectorListModel;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.table.*;
	public class FrameBattleEndWin extends JFrame
	{
		//members define
		private var panelHead:JPanel;
		private var panelHeadP:JPanel;
		private var labelEXP:JLabel;
		private var labelEXPP:JLabel;
		private var labelMoney:JLabel;
		private var labelWood:JLabel;
		private var labelFood:JLabel;
		private var panelItems:JPanel;
		private var btn_battle_end_close:JButton;
		private var btn_battle_end_share:JButton;
		
		//private var btn_close:JButton;
		public function FrameBattleEndWin()
		{
			
			super();
			setDragable(false);
			setClosable(false);
			setResizable(false);
			setTitleBar(null);
			setBorder(new EmptyBorder());
			setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
			
			//component creation
			setSize(new IntDimension(279, 335));
			setPreferredSize(new IntDimension(279, 335));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelHead = new JPanel();
			panelHead.setLocation(new IntPoint(46, 76));
			panelHead.setSize(new IntDimension(69, 69));
			panelHead.setPreferredSize(new IntDimension(69, 69));
			
			panelHeadP = new JPanel();
			panelHeadP.setLocation(new IntPoint(163, 76));
			panelHeadP.setSize(new IntDimension(69, 69));
			panelHeadP.setPreferredSize(new IntDimension(69, 69));
			
			labelEXP = new JLabel();
			labelEXP.setLocation(new IntPoint(62, 153));
			labelEXP.setSize(new IntDimension(80, 16));
			labelEXP.setPreferredSize(new IntDimension(80, 16));
			labelEXP.setText("label");
			labelEXP.setHorizontalAlignment(AsWingConstants.LEFT);
			
			labelEXPP = new JLabel();
			labelEXPP.setLocation(new IntPoint(179, 153));
			labelEXPP.setSize(new IntDimension(80, 16));
			labelEXPP.setPreferredSize(new IntDimension(80, 16));
			labelEXPP.setText("label");
			labelEXPP.setHorizontalAlignment(AsWingConstants.LEFT);
			
			labelMoney = new JLabel();
			labelMoney.setLocation(new IntPoint(62, 182));
			labelMoney.setSize(new IntDimension(160, 16));
			labelMoney.setPreferredSize(new IntDimension(160, 16));
			labelMoney.setText("label");
			labelMoney.setHorizontalAlignment(AsWingConstants.LEFT);
			
			labelWood = new JLabel();
			labelWood.setLocation(new IntPoint(62, 206));
			labelWood.setSize(new IntDimension(70, 16));
			labelWood.setPreferredSize(new IntDimension(70, 16));
			labelWood.setText("label");
			labelWood.setHorizontalAlignment(AsWingConstants.LEFT);
			
			labelFood = new JLabel();
			labelFood.setLocation(new IntPoint(153, 206));
			labelFood.setSize(new IntDimension(80, 16));
			labelFood.setPreferredSize(new IntDimension(80, 16));
			labelFood.setText("label");
			labelFood.setHorizontalAlignment(AsWingConstants.LEFT);
			
			panelItems = new JPanel();
			panelItems.setLocation(new IntPoint(27, 235));
			panelItems.setSize(new IntDimension(225, 45));
			panelItems.setPreferredSize(new IntDimension(225, 45));
			var layout1:GridLayout = new GridLayout();
			layout1.setRows(1);
			layout1.setColumns(5);
			layout1.setHgap(0);
			layout1.setVgap(0);
			panelItems.setLayout(layout1);
			
			btn_battle_end_close = new JButton();
			btn_battle_end_close.setLocation(new IntPoint(80, 295));
			btn_battle_end_close.setSize(new IntDimension(49, 25));
			btn_battle_end_close.setPreferredSize(new IntDimension(49, 25));
			btn_battle_end_close.setText("label");
			
			btn_battle_end_share = new JButton();
			btn_battle_end_share.setLocation(new IntPoint(149, 295));
			btn_battle_end_share.setSize(new IntDimension(49, 25));
			btn_battle_end_share.setPreferredSize(new IntDimension(49, 25));
			btn_battle_end_share.setText("label");
			
			//component layoution
			getContentPane().append(panelHead);
			getContentPane().append(panelHeadP);
			getContentPane().append(labelEXP);
			getContentPane().append(labelEXPP);
			getContentPane().append(labelMoney);
			getContentPane().append(labelWood);
			getContentPane().append(labelFood);
			getContentPane().append(panelItems);
			getContentPane().append(btn_battle_end_close);
			getContentPane().append(btn_battle_end_share);
			
			//------------------------------------------
			setImages();
		}
		private var _mallItems:Array = [];
		public function setImages():void
		{
			setBackgroundDecorator(null);
			var img_background:DisplayObject = Client.getUIElement("img_battle_end_win_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_background));
			setSize(new IntDimension(img_background.width, img_background.height));
			pack();
			setPreferredSize(new IntDimension(img_background.width, img_background.height));
			setLocationXY((Engine.W - width) / 2,(Engine.H - height)/2);
			
			
			var filter:GlowFilter = new GlowFilter(0x000000, 1, 2, 2, 100);
			var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
			
			btn_battle_end_close.wrapSimpleButton(Client.getUIElement("btn_battle_end_close") as SimpleButton);
			btn_battle_end_close.setText("");
			
			btn_battle_end_share.wrapSimpleButton(Client.getUIElement("btn_battle_end_share") as SimpleButton);
			btn_battle_end_share.setText("");
			btn_battle_end_share.setEnabled(false);
			
			panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
			panelHeadP.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
			
			labelEXP.setFont(font);
			labelEXP.setForeground(ASColor.GREEN);
			labelEXP.filters = new Array(filter);
			
			labelEXPP.setFont(font);
			labelEXPP.setForeground(ASColor.GREEN);
			labelEXPP.filters = new Array(filter);
			
			labelMoney.setFont(font);
			labelMoney.setForeground(ASColor.YELLOW);
			labelMoney.filters = new Array(filter);
			
			labelWood.setFont(font);
			labelWood.setForeground(ASColor.ORANGE);
			labelWood.filters = new Array(filter);
			
			labelFood.setFont(font);
			labelFood.setForeground(ASColor.ORANGE);
			labelFood.filters = new Array(filter);
			
			//btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			/*txtResultInfo.setEditable(false);
			txtResultInfo.setBackgroundDecorator(null);
			
			txtResultInfo.setFont(new ASFont("宋体", 12, false, false, false, false));
			//var filter:GlowFilter;
			//filter = new GlowFilter(0x000000, 1, 2, 2, 100);
			txtResultInfo.setForeground(ASColor.WHITE);
			//txtResultInfo.filters = new Array(filter);
			txtResultInfo.setWordWrap(true);
			//txtResultInfo.addEventListener(TextEvent.LINK, linkHandler);
			//txtResultInfo.addEventListener(MouseEvent.CLICK,onClick);
			var css:StyleSheet = new StyleSheet();
			css.parseCSS("a:link { font-size: 13pt;  color: #73280b; } a:hover { font-size: 13pt; color: #ffffff; }a:visited { font-size: 13pt; color: #cccccc; }");
			//css.parseCSS("a {color: #0000FF;} a:hover {text-decoration: underline;}");
			txtResultInfo.setCSS(css);*/
			panelItems.setClipMasked(false);
			for(var i:int = 0; i < 5; i++)
			{
				var item:PanelItem = new PanelItem;
				item.enableClick = false;
				panelItems.append(item);
				_mallItems.push(item);
			}
			
			btn_battle_end_close.addEventListener(MouseEvent.CLICK,function():void
			{
				FrameBattleEndWin.hide();
			});
		
		}
		public function update():void
		{
			for(var i:int = 0; i < 5; i++)
			{
				_mallItems[i].item = null;
			}
			//var img_background:DisplayObject = Client.getUIElement(result == 0 ? "img_battle_end_lose_bg" : "img_battle_end_win_bg") as DisplayObject;
			//setBackgroundDecorator(new AssetBackground(img_background));
			//txtResultInfo.setHtmlText(content);
			labelEXP.setText(SceneBattle.objLastBattleEndAdd.m_nLastBattleEndAddEXP);
			labelEXPP.setText(SceneBattle.objLastBattleEndAdd.m_nLastBattleEndAddEXPP);
			labelMoney.setText(SceneBattle.objLastBattleEndAdd.m_nLastBattleEndAddMoney);
			labelWood.setText(SceneBattle.objLastBattleEndAdd.m_nLastBattleEndAddWood);
			labelFood.setText(SceneBattle.objLastBattleEndAdd.m_nLastBattleEndAddFood);
			
			var nIndex:int = 0;
			for each(var item:Object in SceneBattle.objLastBattleEndAdd.m_listLastBattleEndAddItems)
			{
				_mallItems[nIndex++].item = item;
			}
		}
		public static var _frame:FrameBattleEndWin = null;
		public static function show():void
		{
			if(_frame == null)
			{
				_frame = new FrameBattleEndWin();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.show();
			PanelMainHelp.getInstance().bringToTop(_frame);
			_frame.update();
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
			PanelMain.getInstance().leaveBattle();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
		public function onClose(e:Event):void 
		{
			hide();
		}
	}
}